home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / games / nhak_src.zip / LEV_COMP.C < prev    next >
C/C++ Source or Header  |  1993-03-16  |  35KB  |  1,358 lines

  1.  
  2. # line 1 "lev_comp.y"
  3.  
  4. /*    SCCS Id: @(#)lev_comp.c    3.0    90/01/03
  5. /*    Copyright (c) 1989 by Jean-Christophe Collet */
  6. /* NetHack may be freely redistributed.  See license for details. */
  7.  
  8. /*
  9.  * This file contains the Level Compiler code
  10.  * It may handle special mazes & special room-levels
  11.  */
  12.  
  13. /* block some unused #defines to avoid overloading some cpp's */
  14. #define MONDATA_H    /* comment line for pre-compiled headers */
  15. #define MONFLAG_H    /* comment line for pre-compiled headers */
  16.  
  17. #include "hack.h"
  18. #include "sp_lev.h"
  19. #ifndef O_WRONLY
  20. # include <fcntl.h>
  21. #endif
  22. #ifndef O_CREAT    /* some older BSD systems do not define O_CREAT in <fcntl.h> */
  23. # include <sys/file.h>
  24. #endif
  25.  
  26. void FDECL(yyerror, (char *));
  27. void FDECL(yywarning, (char *));
  28. int NDECL(yylex);
  29. int NDECL(yyparse);
  30.  
  31. int FDECL(get_room_type, (char *));
  32. int FDECL(get_trap_type, (char *));
  33. int FDECL(get_monster_id, (char *, CHAR_P));
  34. int FDECL(get_object_id, (char *, CHAR_P));
  35. boolean FDECL(check_monster_char, (CHAR_P));
  36. boolean FDECL(check_object_char, (CHAR_P));
  37. void FDECL(scan_map, (char *));
  38. void NDECL(store_part);
  39. void FDECL(write_maze, (int, specialmaze *));
  40.  
  41. #ifdef AMIGA
  42. char *fgets();
  43. # undef     fopen
  44. # undef     printf
  45. # undef     Printf
  46. # define    Printf  printf
  47. #ifndef    LATTICE
  48. # define    memset(addr,val,len)    setmem(addr,len,val)
  49. #endif
  50. #endif
  51.  
  52. #ifdef MSDOS
  53. # undef exit
  54. extern void FDECL(exit, (int));
  55. #endif
  56.  
  57. #ifdef MACOS
  58. # undef printf
  59. # undef Printf
  60. # define Printf printf
  61. #endif
  62.  
  63. #undef NULL
  64.  
  65. #define MAX_REGISTERS    10
  66. #define ERR        (-1)
  67.  
  68. struct reg {
  69.     int x1, y1;
  70.     int x2, y2;
  71. }        current_region;
  72.  
  73. struct coord {
  74.     int x;
  75.     int y;
  76. }        current_coord;
  77.  
  78. struct {
  79.     char *name;
  80.     short type;
  81. } trap_types[TRAPNUM-1] = {
  82.     "monster",    MONST_TRAP,
  83.     "statue",    STATUE_TRAP,
  84.     "bear",        BEAR_TRAP,
  85.     "arrow",    ARROW_TRAP,
  86.     "dart",        DART_TRAP,
  87.     "trapdoor",    TRAPDOOR,
  88.     "teleport",    TELEP_TRAP,
  89.     "pit",        PIT,
  90.     "sleep gas",    SLP_GAS_TRAP,
  91.     "magic",    MGTRP,
  92.     "board",    SQBRD,
  93.     "web",        WEB,
  94.     "spiked pit",    SPIKED_PIT,
  95.     "level teleport",LEVEL_TELEP,
  96. #ifdef SPELLS
  97.     "anti magic",    ANTI_MAGIC,
  98. #endif
  99.     "rust",        RUST_TRAP
  100. #ifdef POLYSELF
  101.     , "polymorph",    POLY_TRAP
  102. #endif
  103. #ifdef ARMY
  104.     , "land mine",    LANDMINE
  105. #endif
  106.   };
  107.  
  108. struct {
  109.     char *name;
  110.     int type;
  111. } room_types[SHOPBASE-1] = {
  112.     /* for historical reasons, room types are not contiguous numbers */
  113.     /* (type 1 is skipped) */
  114.     "ordinary",    OROOM,
  115. #ifdef THRONES
  116.     "throne",    COURT,
  117. #endif
  118.     "swamp",    SWAMP,
  119.     "vault",    VAULT,
  120.     "beehive",    BEEHIVE,
  121.     "morgue",    MORGUE,
  122. #ifdef ARMY
  123.     "barracks",    BARRACKS,
  124. #endif
  125.     "zoo",        ZOO,
  126.     "temple",    TEMPLE,
  127.     "shop",        SHOPBASE,
  128. };
  129.  
  130. short db_dirs[4] = {
  131.     DB_NORTH,
  132.     DB_EAST,
  133.     DB_SOUTH,
  134.     DB_WEST
  135. };
  136.  
  137. #ifdef ALTARS
  138. static altar *tmpaltar[256];
  139. #endif /* ALTARS /**/
  140. static lad *tmplad[256];
  141. static digpos *tmpdig[256];
  142. static char *tmpmap[ROWNO];
  143. static region *tmpreg[16];
  144. static door *tmpdoor[256];
  145. static trap *tmptrap[256];
  146. static monster *tmpmonst[256];
  147. static object *tmpobj[256];
  148. static drawbridge *tmpdb[256];
  149. static walk *tmpwalk[256];
  150. static mazepart *tmppart[10];
  151. static room *tmproom[MAXNROFROOMS];
  152. static specialmaze maze;
  153.  
  154. static char olist[MAX_REGISTERS], mlist[MAX_REGISTERS];
  155. static struct coord plist[MAX_REGISTERS];
  156. static int n_olist = 0, n_mlist = 0, n_plist = 0;
  157.  
  158. unsigned int nreg = 0, ndoor = 0, ntrap = 0, nmons = 0, nobj = 0;
  159. unsigned int ndb = 0, nwalk = 0, npart = 0, ndig = 0, nlad = 0;
  160. #ifdef ALTARS
  161. unsigned int naltar = 0;
  162. #endif /* ALTARS /*/
  163.  
  164. unsigned int max_x_map, max_y_map;
  165.  
  166. extern int fatal_error;
  167. extern char* fname;
  168.  
  169.  
  170. # line 169 "lev_comp.y"
  171. typedef union 
  172. {
  173.     int    i;
  174.     char*    map;
  175. } YYSTYPE;
  176. # define CHAR 257
  177. # define INTEGER 258
  178. # define MAZE_ID 259
  179. # define LEVEL_ID 260
  180. # define GEOMETRY_ID 261
  181. # define OBJECT_ID 262
  182. # define MONSTER_ID 263
  183. # define TRAP_ID 264
  184. # define DOOR_ID 265
  185. # define DRAWBRIDGE_ID 266
  186. # define MAZEWALK_ID 267
  187. # define REGION_ID 268
  188. # define RANDOM_OBJECTS_ID 269
  189. # define RANDOM_MONSTERS_ID 270
  190. # define RANDOM_PLACES_ID 271
  191. # define ALTAR_ID 272
  192. # define LADDER_ID 273
  193. # define NON_DIGGABLE_ID 274
  194. # define ROOM_ID 275
  195. # define DOOR_STATE 276
  196. # define LIGHT_STATE 277
  197. # define DIRECTION 278
  198. # define RANDOM_TYPE 279
  199. # define O_REGISTER 280
  200. # define M_REGISTER 281
  201. # define P_REGISTER 282
  202. # define A_REGISTER 283
  203. # define ALIGNMENT 284
  204. # define LEFT_OR_RIGHT 285
  205. # define CENTER 286
  206. # define TOP_OR_BOT 287
  207. # define ALTAR_TYPE 288
  208. # define UP_OR_DOWN 289
  209. # define STRING 290
  210. # define MAP_ID 291
  211. #define yyclearin yychar = -1
  212. #define yyerrok yyerrflag = 0
  213. extern int yychar;
  214. extern short yyerrflag;
  215. #ifndef YYMAXDEPTH
  216. #define YYMAXDEPTH 150
  217. #endif
  218. YYSTYPE yylval, yyval;
  219. # define YYERRCODE 256
  220.  
  221. # line 654 "lev_comp.y"
  222.  
  223.  
  224. /* 
  225.  * Find the type of a room in the table, knowing its name.
  226.  */
  227.  
  228. int
  229. get_room_type(s)
  230. char *s;
  231. {
  232.     register int i;
  233.     
  234.     for(i=0; i < SHOPBASE -1; i++)
  235.         if (!strcmp(s, room_types[i].name))
  236.         return ((int) room_types[i].type);
  237.     return ERR;
  238. }
  239.  
  240. /* 
  241.  * Find the type of a trap in the table, knowing its name.
  242.  */
  243.  
  244. int
  245. get_trap_type(s)
  246. char *s;
  247. {
  248.     register int i;
  249.     
  250.     for(i=0; i < TRAPNUM - 1; i++)
  251.         if(!strcmp(s,trap_types[i].name))
  252.         return((int)trap_types[i].type);
  253.     return ERR;
  254. }
  255.  
  256. /* 
  257.  * Find the index of a monster in the table, knowing its name.
  258.  */
  259.  
  260. int
  261. get_monster_id(s, c)
  262. char *s;
  263. char c;
  264. {
  265.     register int i;
  266.     
  267.     for(i=0; mons[i].mname[0]; i++)
  268.         if(!strncmp(s, mons[i].mname, strlen(mons[i].mname))
  269.            && c == mons[i].mlet)
  270.         return i;
  271.     return ERR;
  272. }
  273.  
  274. /* 
  275.  * Find the index of an object in the table, knowing its name.
  276.  */
  277.  
  278. int
  279. get_object_id(s, c)
  280. char *s;
  281. char c;
  282. {
  283.     register int i;
  284.     
  285.     for(i=0; i<=NROFOBJECTS;i++)
  286.         if(objects[i].oc_name &&
  287.            !strncmp(s, objects[i].oc_name, strlen(objects[i].oc_name))
  288.            && c == objects[i].oc_olet)
  289.         return i;
  290.     return ERR;
  291. }
  292.  
  293. /* 
  294.  * Is the character 'c' a valid monster class ?
  295.  */
  296.  
  297. boolean
  298. check_monster_char(c)
  299. char c;
  300. {
  301.     register int i;
  302.     
  303.     for(i=0; mons[i].mname[0]; i++)
  304.         if( c ==  mons[i].mlet)
  305.         return 1;
  306.     return(0);
  307. }
  308.  
  309. /* 
  310.  * Is the character 'c' a valid object class ?
  311.  */
  312.  
  313. boolean
  314. check_object_char(c)
  315. char c;
  316. {
  317.     register int i;
  318.     
  319.     for(i=0; i<=NROFOBJECTS;i++)
  320.         if( c == objects[i].oc_olet)
  321.         return 1;
  322.     return 0;
  323. }
  324.  
  325. /* 
  326.  * Yep! LEX gives us the map in a raw mode.
  327.  * Just analyze it here.
  328.  */
  329.  
  330. void scan_map(map)
  331. char *map;
  332. {
  333.     register int i, len;
  334.     register char *s1, *s2;
  335.     int max_len = 0;
  336.     int max_hig = 0;
  337.     
  338.     /* First : find the max width of the map */
  339.  
  340.     s1 = map;
  341.     while (s1 && *s1) {
  342.         s2 = index(s1, '\n');
  343.         if (s2) {
  344.             if (s2-s1 > max_len)
  345.                 max_len = s2-s1;
  346.             s1 = s2 + 1;
  347.         } else {
  348.             if (strlen(s1) > max_len)
  349.                 max_len = strlen(s1);
  350.             s1 = (char *) 0;
  351.         }
  352.     }
  353.  
  354.     /* Then parse it now */
  355.  
  356.     while (map && *map) {
  357.         tmpmap[max_hig] = (char *) alloc(max_len);
  358.         s1 = index(map, '\n');
  359.         if (s1) {
  360.             len = s1 - map;
  361.             s1++;
  362.         } else {
  363.             len = strlen(map);
  364.             s1 = map + len;
  365.         }
  366.         for(i=0; i<len; i++)
  367.             switch(map[i]) {
  368.               case '-' : tmpmap[max_hig][i] = HWALL; break;
  369.               case '|' : tmpmap[max_hig][i] = VWALL; break;
  370.               case '+' : tmpmap[max_hig][i] = DOOR; break;
  371.               case 'S' : tmpmap[max_hig][i] = SDOOR; break;
  372.               case '{' : 
  373. #ifdef FOUNTAINS
  374.                   tmpmap[max_hig][i] = FOUNTAIN;
  375. #else
  376.                   tmpmap[max_hig][i] = ROOM;
  377.                   yywarning("Fountains are not allowed in this version!  Ignoring...");
  378. #endif
  379.                   break;
  380.               case '\\' : 
  381. #ifdef THRONES
  382.                   tmpmap[max_hig][i] = THRONE;
  383. #else
  384.                   tmpmap[max_hig][i] = ROOM;
  385.                   yywarning("Thrones are not allowed in this version!  Ignoring...");
  386. #endif
  387.                   break;
  388.               case 'K' : 
  389. #ifdef SINKS
  390.                   tmpmap[max_hig][i] = SINK;
  391. #else
  392.                   tmpmap[max_hig][i] = ROOM;
  393.                   yywarning("Sinks are not allowed in this version!  Ignoring...");
  394. #endif
  395.                   break;
  396.               case '}' : tmpmap[max_hig][i] = MOAT; break;
  397.               case '#' : tmpmap[max_hig][i] = CORR; break;
  398.               default  : tmpmap[max_hig][i] = ROOM; break;
  399.             }
  400.         while(i < max_len)
  401.             tmpmap[max_hig][i++] = ROOM;
  402.         map = s1;
  403.         max_hig++;
  404.     }
  405.  
  406.     /* Memorize boundaries */
  407.  
  408.     max_x_map = max_len - 1;
  409.     max_y_map = max_hig - 1;
  410.  
  411.     /* Store the map into the mazepart structure */
  412.  
  413.     tmppart[npart]->xsize = max_len;
  414.     tmppart[npart]->ysize = max_hig;
  415.     tmppart[npart]->map = (char **) alloc(max_hig*sizeof(char *));
  416.     for(i = 0; i< max_hig; i++)
  417.         tmppart[npart]->map[i] = tmpmap[i];
  418. }
  419.  
  420. /* 
  421.  * Here we want to store the maze part we just got.
  422.  */
  423.  
  424. void
  425. store_part()
  426. {
  427.     register int i;
  428.  
  429.     /* Ok, We got the whole part, now we store it. */
  430.     
  431.     /* The Regions */
  432.  
  433.     if(tmppart[npart]->nreg = nreg) {
  434.         tmppart[npart]->regions = (region**)alloc(sizeof(region*) * nreg);
  435.         for(i=0;i<nreg;i++)
  436.             tmppart[npart]->regions[i] = tmpreg[i];
  437.     }
  438.     nreg = 0;
  439.  
  440.     /* the doors */
  441.  
  442.     if(tmppart[npart]->ndoor = ndoor) {
  443.         tmppart[npart]->doors = (door **)alloc(sizeof(door *) * ndoor);
  444.         for(i=0;i<ndoor;i++)
  445.             tmppart[npart]->doors[i] = tmpdoor[i];
  446.     }
  447.     ndoor = 0;
  448.  
  449.     /* the traps */
  450.  
  451.     if(tmppart[npart]->ntraps = ntrap) {
  452.         tmppart[npart]->traps = (trap **)alloc(sizeof(trap*) * ntrap);
  453.         for(i=0;i<ntrap;i++)
  454.             tmppart[npart]->traps[i] = tmptrap[i];
  455.     }
  456.     ntrap = 0;
  457.  
  458.     /* the monsters */
  459.  
  460.     if(tmppart[npart]->nmonster = nmons) {
  461.         tmppart[npart]->monsters = (monster**)alloc(sizeof(monster*)*nmons);
  462.         for(i=0;i<nmons;i++)
  463.             tmppart[npart]->monsters[i] = tmpmonst[i];
  464.     }
  465.     nmons = 0;
  466.  
  467.     /* the objects */
  468.  
  469.     if(tmppart[npart]->nobjects = nobj) {
  470.         tmppart[npart]->objects = (object**)alloc(sizeof(object*)*nobj);
  471.         for(i=0;i<nobj;i++)
  472.             tmppart[npart]->objects[i] = tmpobj[i];
  473.     }
  474.     nobj = 0;
  475.  
  476.     /* the drawbridges */
  477.  
  478.     if(tmppart[npart]->ndrawbridge = ndb) {
  479.         tmppart[npart]->drawbridges = (drawbridge**)alloc(sizeof(drawbridge*)*ndb);
  480.         for(i=0;i<ndb;i++)
  481.             tmppart[npart]->drawbridges[i] = tmpdb[i];
  482.     }
  483.     ndb = 0;
  484.  
  485.     /* The walkmaze directives */
  486.  
  487.     if(tmppart[npart]->nwalk = nwalk) {
  488.         tmppart[npart]->walks = (walk**)alloc(sizeof(walk*)*nwalk);
  489.         for(i=0;i<nwalk;i++)
  490.             tmppart[npart]->walks[i] = tmpwalk[i];
  491.     }
  492.     nwalk = 0;
  493.  
  494.     /* The non_diggable directives */
  495.  
  496.     if(tmppart[npart]->ndig = ndig) {
  497.         tmppart[npart]->digs = (digpos **) alloc(sizeof(digpos*) * ndig);
  498.         for(i=0;i<ndig;i++)
  499.             tmppart[npart]->digs[i] = tmpdig[i];
  500.     }
  501.     ndig = 0;
  502.  
  503.     /* The ladders */
  504.  
  505.     if(tmppart[npart]->nlad = nlad) {
  506.         tmppart[npart]->lads = (lad **) alloc(sizeof(lad*) * nlad);
  507.         for(i=0;i<nlad;i++)
  508.             tmppart[npart]->lads[i] = tmplad[i];
  509.     }
  510.     nlad = 0;
  511. #ifdef ALTARS
  512.     /* The altars */
  513.  
  514.     if(tmppart[npart]->naltar = naltar) {
  515.         tmppart[npart]->altars = (altar**)alloc(sizeof(altar*) * naltar);
  516.         for(i=0;i<naltar;i++)
  517.             tmppart[npart]->altars[i] = tmpaltar[i];
  518.     }
  519.     naltar = 0;
  520. #endif /* ALTARS /**/
  521.     npart++;
  522.     n_plist = n_mlist = n_olist = 0;
  523. }
  524.  
  525. /* 
  526.  * Here we write the structure of the maze in the specified file (fd).
  527.  * Also, we have to free the memory allocated via alloc()
  528.  */
  529.  
  530. void
  531. write_maze(fd, maze)
  532. int fd;
  533. specialmaze *maze;
  534. {
  535.     char c;
  536.     short i,j;
  537.     mazepart *pt;
  538.  
  539.     c = 2;
  540.     (void) write(fd, &c, 1);    /* Header for special mazes */
  541.     (void) write(fd, &(maze->numpart), 1);    /* Number of parts */
  542.     for(i=0;i<maze->numpart;i++) {
  543.         pt = maze->parts[i];
  544.  
  545.         /* First, write the map */
  546.  
  547.         (void) write(fd, &(pt->halign), 1);
  548.         (void) write(fd, &(pt->valign), 1);
  549.         (void) write(fd, &(pt->xsize), 1);
  550.         (void) write(fd, &(pt->ysize), 1);
  551.         for(j=0;j<pt->ysize;j++) {
  552.             (void) write(fd, pt->map[j], pt->xsize);
  553.             free(pt->map[j]);
  554.         }
  555.         free(pt->map);
  556.  
  557.         /* The random registers */
  558.         (void) write(fd, &(pt->nrobjects), 1);
  559.         if(pt->nrobjects) {
  560.             (void) write(fd, pt->robjects, pt->nrobjects);
  561.             free(pt->robjects);
  562.         }
  563.         (void) write(fd, &(pt->nloc), 1);
  564.         if(pt->nloc) {
  565.         (void) write(fd,pt->rloc_x, pt->nloc);
  566.         (void) write(fd,pt->rloc_y, pt->nloc);
  567.         free(pt->rloc_x);
  568.         free(pt->rloc_y);
  569.         }
  570.         (void) write(fd,&(pt->nrmonst), 1);
  571.         if(pt->nrmonst) {
  572.             (void) write(fd, pt->rmonst, pt->nrmonst);
  573.             free(pt->rmonst);
  574.         }
  575.  
  576.         /* subrooms */
  577.         (void) write(fd, &(pt->nreg), 1);
  578.         for(j=0;j<pt->nreg;j++) {
  579.             (void) write(fd,(genericptr_t) pt->regions[j], sizeof(region));
  580.             free(pt->regions[j]);
  581.         }
  582.         if(pt->nreg > 0)
  583.         free(pt->regions);
  584.  
  585.         /* the doors */
  586.         (void) write(fd,&(pt->ndoor),1);
  587.         for(j=0;j<pt->ndoor;j++) {
  588.             (void) write(fd,(genericptr_t) pt->doors[j], sizeof(door));
  589.             free(pt->doors[j]);
  590.         }
  591.         if (pt->ndoor > 0)
  592.         free(pt->doors);
  593.  
  594.         /* The traps */
  595.         (void) write(fd,&(pt->ntraps), 1);
  596.         for(j=0;j<pt->ntraps;j++) {
  597.             (void) write(fd,(genericptr_t) pt->traps[j], sizeof(trap));
  598.             free(pt->traps[j]);
  599.         }
  600.         if (pt->ntraps)
  601.         free(pt->traps);
  602.  
  603.         /* The monsters */
  604.         (void) write(fd, &(pt->nmonster), 1);
  605.         for(j=0;j<pt->nmonster;j++) {
  606.             (void) write(fd,(genericptr_t) pt->monsters[j], sizeof(monster));
  607.             free(pt->monsters[j]);
  608.         }
  609.         if (pt->nmonster > 0)
  610.         free(pt->monsters);
  611.  
  612.         /* The objects */
  613.         (void) write(fd, &(pt->nobjects), 1);
  614.         for(j=0;j<pt->nobjects;j++) {
  615.             (void) write(fd,(genericptr_t) pt->objects[j], sizeof(object));
  616.             free(pt->objects[j]);
  617.         }
  618.         if(pt->nobjects > 0)
  619.         free(pt->objects);
  620.  
  621.         /* The drawbridges */
  622.         (void) write(fd, &(pt->ndrawbridge),1);
  623.         for(j=0;j<pt->ndrawbridge;j++) {
  624.             (void) write(fd,(genericptr_t) pt->drawbridges[j], sizeof(drawbridge));
  625.             free(pt->drawbridges[j]);
  626.         }
  627.         if(pt->ndrawbridge > 0)
  628.         free(pt->drawbridges);
  629.  
  630.         /* The mazewalk directives */
  631.         (void) write(fd, &(pt->nwalk), 1);
  632.         for(j=0; j<pt->nwalk; j++) {
  633.             (void) write(fd,(genericptr_t) pt->walks[j], sizeof(walk));
  634.             free(pt->walks[j]);
  635.         }
  636.         if (pt->nwalk > 0)
  637.         free(pt->walks);
  638.  
  639.         /* The non_diggable directives */
  640.         (void) write(fd, &(pt->ndig), 1);
  641.         for(j=0;j<pt->ndig;j++) {
  642.             (void) write(fd,(genericptr_t) pt->digs[j], sizeof(digpos));
  643.             free(pt->digs[j]);
  644.         }
  645.         if (pt->ndig > 0)
  646.         free(pt->digs);
  647.  
  648.         /* The ladders */
  649.         (void) write(fd, &(pt->nlad), 1);
  650.         for(j=0;j<pt->nlad;j++) {
  651.             (void) write(fd,(genericptr_t) pt->lads[j], sizeof(lad));
  652.             free(pt->lads[j]);
  653.         }
  654.         if (pt->nlad > 0)
  655.         free(pt->lads);
  656. #ifdef ALTARS
  657.         /* The altars */
  658.         (void) write(fd, &(pt->naltar), 1);
  659.         for(j=0;j<pt->naltar;j++) {
  660.             (void) write(fd,(genericptr_t) pt->altars[j], sizeof(altar));
  661.             free(pt->altars[j]);
  662.         }
  663.         if (pt->naltar > 0)
  664.         free(pt->altars);
  665. #endif /* ALTARS /**/
  666.         free(pt);
  667.     }
  668. }
  669. short yyexca[] ={
  670. -1, 1,
  671.     0, -1,
  672.     -2, 0,
  673. -1, 67,
  674.     44, 27,
  675.     -2, 26,
  676.     };
  677. # define YYNPROD 87
  678. # define YYLAST 251
  679. short yyact[]={
  680.  
  681.  165, 130, 126,  91,  16,  19, 169, 146,  69,  72,
  682.  145,  19,  19,  19,  19, 168,  75,  74,  26,  27,
  683.  143, 137,  12, 138, 144, 141,  65,  87, 134,   6,
  684.   88,  78, 174,  80,  40,  39,  42,  41,  43,  46,
  685.   44, 171, 170, 156,  45,  47,  48, 148,  83,  85,
  686.   22,  24,  23, 135, 131, 127, 116, 105,  72,  65,
  687.   18,  92,  93,  86,  66,  70, 172,  63, 154, 152,
  688.  150, 158, 114, 110, 108,  97,  62,  61,  60,  59,
  689.   58,  57,  56,  55,  54,  53,  51,  50,  49,  17,
  690.   13,  64, 173,  71, 166, 157, 155, 153, 151, 149,
  691.  139, 122, 121, 119, 118, 117, 115, 113, 112, 111,
  692.  109, 107, 106,  68, 103,  52, 175,  90, 159,  69,
  693.   98,  99, 100, 101,   8,   2,  94,  84,  79,   7,
  694.   81,  76,  38,  37,  14,  36,  35,  34, 102,  33,
  695.   32,  31,  30,  29,  28, 104,  82,  77,  67,  21,
  696.   11,  20,  15,  10,   9,   4,   3,   1, 128, 124,
  697.    5, 142, 167, 140, 136, 163,  89,  73, 125,  25,
  698.  129, 120, 123, 132, 133,   0,   0,   0,   0,   0,
  699.    0,   0,   0,   0,  68,   0, 147,   0,   0,   0,
  700.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  701.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  702.    0, 160,   0, 161,   0,   0, 164, 162,   0,   0,
  703.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  704.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  705.    0,   0,   0,   0,   0,   0,   0,  95,   0,   0,
  706.   96 };
  707. short yypact[]={
  708.  
  709. -230,-1000,-1000,-230,-1000,-239,  32,-1000,-1000,-239,
  710. -1000,-287,  31,-285,-1000,-219,-1000,-267,-1000,-1000,
  711. -228,-1000,  30,  29,  28,  71,-1000,-1000,-1000,-1000,
  712. -1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,  27,
  713.   26,  25,  24,  23,  22,  21,  20,  19,  18,-198,
  714.   79,-199,-270,-248,-231,-249,-276, -32,  80, -32,
  715.  -32, -32,  80,-1000,  70,-1000,-1000,-1000,-1000,-201,
  716. -1000,  68,-1000,-1000,-1000,-1000,  67,-1000,-1000,-1000,
  717.  -17,  66,-1000,-1000,-1000, -18,  65,-1000,-1000,  64,
  718. -1000,-1000,  63,-1000,-1000,-1000, -19,  62,-202,  61,
  719.   60,  59,-1000,-198,  58,  57,-199,-277,-203,-278,
  720. -204, -32, -32,-250,-205,-256,  56,-259,-268,-282,
  721. -1000,  79,-211,-1000,  55,-1000,-1000, -23,  54,-1000,
  722. -1000, -24,-1000,-1000,  53, -25,  52,-1000,-1000,-215,
  723.   51,-1000,-1000,-1000, -20,-1000,-1000,-1000,  77, -32,
  724. -1000, -32,-1000,-249,-1000,-279,  50,-273,-216,-1000,
  725. -1000,-1000,-1000,-1000,-1000,-1000,-217,-1000,-1000,-1000,
  726.  -27,  48,-1000,-226,  75,-1000 };
  727. short yypgo[]={
  728.  
  729.    0, 169, 167, 166, 165,  63, 164, 163, 162, 161,
  730.   60, 160, 159, 158, 157, 125, 156, 155, 124, 154,
  731.  153, 152, 151, 150, 149,  67,  64,  65,  91,  93,
  732.  148, 145, 144, 143, 142, 141, 140, 139, 137, 136,
  733.  135, 133, 132, 131,  61, 130,  75, 128, 127,  62,
  734.  126 };
  735. short yyr1[]={
  736.  
  737.    0,  14,  14,  15,  15,  16,  17,  11,  18,  18,
  738.   19,  20,  23,   1,   1,   2,   2,  21,  21,  24,
  739.   24,  24,  25,  25,  27,  27,  26,  31,  26,  22,
  740.   22,  32,  32,  32,  32,  32,  32,  32,  32,  32,
  741.   32,  33,  34,  35,  36,  37,  40,  41,  42,  38,
  742.   39,  43,  43,  43,  45,  45,  45,  12,  12,  13,
  743.   13,   3,   3,   4,   4,  44,  44,  44,   5,   5,
  744.    6,   6,   7,   7,   7,   8,   8,  50,  48,  47,
  745.    9,  30,  29,  28,  10,  49,  46 };
  746. short yyr2[]={
  747.  
  748.    0,   0,   1,   1,   2,   1,   2,   3,   1,   2,
  749.    3,   2,   5,   1,   1,   1,   1,   0,   2,   3,
  750.    3,   3,   1,   3,   1,   3,   1,   0,   4,   0,
  751.    2,   1,   1,   1,   1,   1,   1,   1,   1,   1,
  752.    1,   7,   7,   5,   5,   7,   5,   5,   3,   7,
  753.    7,   1,   1,   1,   1,   1,   1,   1,   1,   1,
  754.    1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
  755.    1,   1,   1,   1,   1,   1,   1,   4,   4,   4,
  756.    4,   1,   1,   1,   1,   5,   9 };
  757. short yychk[]={
  758.  
  759. -1000, -14, -15, -16, -17, -11, 259, -15, -18, -19,
  760.  -20, -23, 261,  58, -18, -21, 291,  58, -10, 290,
  761.  -22, -24, 269, 271, 270,  -1, 285, 286, -32, -33,
  762.  -34, -35, -36, -37, -38, -39, -40, -41, -42, 263,
  763.  262, 265, 264, 266, 268, 272, 267, 273, 274,  58,
  764.   58,  58,  44,  58,  58,  58,  58,  58,  58,  58,
  765.   58,  58,  58, -25, -28, 257, -26, -30, -49,  40,
  766.  -27, -29, 257,  -2, 287, 286, -43, -29, 279, -47,
  767.  281, -45, -28, 279, -48, 280,  -5, 276, 279,  -3,
  768.  -10, 279, -44, -49, -50, 279, 282, -46,  40, -44,
  769.  -44, -44, -46,  44, -31, 258,  44,  44,  91,  44,
  770.   91,  44,  44,  44,  91,  44, 258,  44,  44,  44,
  771.  -25,  44,  44, -27, -12, -10, 279, 258, -13, -10,
  772.  279, 258, -44, -44, 278, 258,  -6, 277, 279,  44,
  773.   -7, 284,  -9, 279, 283, 278, 289, -26, 258,  44,
  774.   93,  44,  93,  44,  93,  44, 258,  44,  91,  41,
  775.  -44, -44,  -5,  -4, -10, 279,  44,  -8, 288, 279,
  776.  258, 258,  93,  44, 258,  41 };
  777. short yydef[]={
  778.  
  779.    1,  -2,   2,   3,   5,   0,   0,   4,   6,   8,
  780.   17,   0,   0,   0,   9,  29,  11,   0,   7,  84,
  781.   10,  18,   0,   0,   0,   0,  13,  14,  30,  31,
  782.   32,  33,  34,  35,  36,  37,  38,  39,  40,   0,
  783.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  784.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  785.    0,   0,   0,  19,  22,  83,  20,  -2,  81,   0,
  786.   21,  24,  82,  12,  15,  16,   0,  51,  52,  53,
  787.    0,   0,  54,  55,  56,   0,   0,  68,  69,   0,
  788.   61,  62,   0,  65,  66,  67,   0,   0,   0,   0,
  789.    0,   0,  48,   0,   0,   0,   0,   0,   0,   0,
  790.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  791.   23,   0,   0,  25,   0,  57,  58,   0,   0,  59,
  792.   60,   0,  43,  44,   0,   0,   0,  70,  71,   0,
  793.    0,  72,  73,  74,   0,  46,  47,  28,   0,   0,
  794.   79,   0,  78,   0,  77,   0,   0,   0,   0,  85,
  795.   41,  42,  45,  49,  63,  64,   0,  50,  75,  76,
  796.    0,   0,  80,   0,   0,  86 };
  797. #ifndef lint
  798. static char yaccpar_sccsid[] = "@(#)yaccpar    4.1    (Berkeley)    2/11/83";
  799. #endif not lint
  800.  
  801. #
  802. # define YYFLAG -1000
  803. # define YYERROR goto yyerrlab
  804. # define YYACCEPT return(0)
  805. # define YYABORT return(1)
  806.  
  807. /*    parser for yacc output    */
  808.  
  809. #ifdef YYDEBUG
  810. int yydebug = 0; /* 1 for debugging */
  811. #endif
  812. YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
  813. int yychar = -1; /* current input token number */
  814. int yynerrs = 0;  /* number of errors */
  815. short yyerrflag = 0;  /* error recovery flag */
  816.  
  817. yyparse() {
  818.  
  819.     short yys[YYMAXDEPTH];
  820.     short yyj, yym;
  821.     register YYSTYPE *yypvt;
  822.     register short yystate, *yyps, yyn;
  823.     register YYSTYPE *yypv;
  824.     register short *yyxi;
  825.  
  826.     yystate = 0;
  827.     yychar = -1;
  828.     yynerrs = 0;
  829.     yyerrflag = 0;
  830.     yyps= &yys[-1];
  831.     yypv= &yyv[-1];
  832.  
  833.  yystack:    /* put a state and value onto the stack */
  834.  
  835. #ifdef YYDEBUG
  836.     if( yydebug  ) printf( "state %d, char 0%o\n", yystate, yychar );
  837. #endif
  838.         if( ++yyps> &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); }
  839.         *yyps = yystate;
  840.         ++yypv;
  841.         *yypv = yyval;
  842.  
  843.  yynewstate:
  844.  
  845.     yyn = yypact[yystate];
  846.  
  847.     if( yyn<= YYFLAG ) goto yydefault; /* simple state */
  848.  
  849.     if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
  850.     if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;
  851.  
  852.     if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
  853.         yychar = -1;
  854.         yyval = yylval;
  855.         yystate = yyn;
  856.         if( yyerrflag > 0 ) --yyerrflag;
  857.         goto yystack;
  858.         }
  859.  
  860.  yydefault:
  861.     /* default state action */
  862.  
  863.     if( (yyn=yydef[yystate]) == -2 ) {
  864.         if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
  865.         /* look through exception table */
  866.  
  867.         for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
  868.  
  869.         while( *(yyxi+=2) >= 0 ){
  870.             if( *yyxi == yychar ) break;
  871.             }
  872.         if( (yyn = yyxi[1]) < 0 ) return(0);   /* accept */
  873.         }
  874.  
  875.     if( yyn == 0 ){ /* error */
  876.         /* error ... attempt to resume parsing */
  877.  
  878.         switch( yyerrflag ){
  879.  
  880.         case 0:   /* brand new error */
  881.  
  882.             yyerror( "syntax error" );
  883.         yyerrlab:
  884.             ++yynerrs;
  885.  
  886.         case 1:
  887.         case 2: /* incompletely recovered error ... try again */
  888.  
  889.             yyerrflag = 3;
  890.  
  891.             /* find a state where "error" is a legal shift action */
  892.  
  893.             while ( yyps >= yys ) {
  894.                yyn = yypact[*yyps] + YYERRCODE;
  895.                if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
  896.                   yystate = yyact[yyn];  /* simulate a shift of "error" */
  897.                   goto yystack;
  898.                   }
  899.                yyn = yypact[*yyps];
  900.  
  901.                /* the current yyps has no shift onn "error", pop stack */
  902.  
  903. #ifdef YYDEBUG
  904.                if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
  905. #endif
  906.                --yyps;
  907.                --yypv;
  908.                }
  909.  
  910.             /* there is no state on the stack with an error shift ... abort */
  911.  
  912.     yyabort:
  913.             return(1);
  914.  
  915.  
  916.         case 3:  /* no shift yet; clobber input char */
  917.  
  918. #ifdef YYDEBUG
  919.             if( yydebug ) printf( "error recovery discards char %d\n", yychar );
  920. #endif
  921.  
  922.             if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
  923.             yychar = -1;
  924.             goto yynewstate;   /* try again in the same state */
  925.  
  926.             }
  927.  
  928.         }
  929.  
  930.     /* reduction by production yyn */
  931.  
  932. #ifdef YYDEBUG
  933.         if( yydebug ) printf("reduce %d\n",yyn);
  934. #endif
  935.         yyps -= yyr2[yyn];
  936.         yypvt = yypv;
  937.         yypv -= yyr2[yyn];
  938.         yyval = yypv[1];
  939.         yym=yyn;
  940.             /* consult goto table to find next state */
  941.         yyn = yyr1[yyn];
  942.         yyj = yypgo[yyn] + *yyps + 1;
  943.         if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
  944.         switch(yym){
  945.             
  946. case 6:
  947. # line 201 "lev_comp.y"
  948. {
  949.               int fout, i;
  950.  
  951.               if (fatal_error > 0)
  952.                   fprintf(stderr,"%s : %d errors detected. No output created!\n", fname, fatal_error);
  953.               else {
  954. #ifdef MACOS
  955.                   OSErr    result;
  956.                   
  957.                   result = Create(CtoPstr(yypvt[-1].map), 0, CREATOR, AUXIL_TYPE);
  958.                   (void)PtoCstr(yypvt[-1].map);
  959. #endif        
  960.                   fout = open(yypvt[-1].map, O_WRONLY | O_CREAT
  961. #if defined(MSDOS) || defined(MACOS)
  962.                           | O_BINARY
  963. #endif /* MSDOS || MACOS */
  964.                           , 0644);
  965.                   if (fout < 0) {
  966.                       yyerror("Can't open output file!!");
  967.                       exit(1);
  968.                   }
  969.                   maze.numpart = npart;
  970.                   maze.parts = (mazepart**) alloc(sizeof(mazepart*)*npart);
  971.                   for(i=0;i<npart;i++)
  972.                       maze.parts[i] = tmppart[i];
  973.                   write_maze(fout, &maze);
  974.                   (void) close(fout);
  975.                   npart = 0;
  976.               }
  977.           } break;
  978. case 7:
  979. # line 233 "lev_comp.y"
  980. {
  981.               yyval.map = yypvt[-0].map;
  982.           } break;
  983. case 10:
  984. # line 241 "lev_comp.y"
  985. {
  986.             store_part();
  987.           } break;
  988. case 11:
  989. # line 246 "lev_comp.y"
  990. {
  991.             tmppart[npart] = (mazepart *) alloc(sizeof(mazepart));
  992.             tmppart[npart]->halign = yypvt[-1].i % 10;
  993.             tmppart[npart]->valign = yypvt[-1].i / 10;
  994.             tmppart[npart]->nrobjects = 0;
  995.             tmppart[npart]->nloc = 0;
  996.             tmppart[npart]->nrmonst = 0;
  997.             scan_map(yypvt[-0].map);
  998.           } break;
  999. case 12:
  1000. # line 257 "lev_comp.y"
  1001. {
  1002.               yyval.i = yypvt[-2].i + ( yypvt[-0].i * 10 );
  1003.           } break;
  1004. case 19:
  1005. # line 271 "lev_comp.y"
  1006. {
  1007.               if (tmppart[npart]->nrobjects)
  1008.                   yyerror("Object registers already initialized!");
  1009.               else {
  1010.                   tmppart[npart]->robjects = (char *) alloc(n_olist);
  1011.                   memcpy(tmppart[npart]->robjects, olist, n_olist);
  1012.                   tmppart[npart]->nrobjects = n_olist;
  1013.               }
  1014.           } break;
  1015. case 20:
  1016. # line 281 "lev_comp.y"
  1017. {
  1018.               if (tmppart[npart]->nloc)
  1019.                   yyerror("Location registers already initialized!");
  1020.               else {
  1021.                   register int i;
  1022.                   tmppart[npart]->rloc_x = (char *) alloc(n_plist);
  1023.                   tmppart[npart]->rloc_y = (char *) alloc(n_plist);
  1024.                   for(i=0;i<n_plist;i++) {
  1025.                       tmppart[npart]->rloc_x[i] = plist[i].x;
  1026.                       tmppart[npart]->rloc_y[i] = plist[i].y;
  1027.                   }
  1028.                   tmppart[npart]->nloc = n_plist;
  1029.               }
  1030.           } break;
  1031. case 21:
  1032. # line 296 "lev_comp.y"
  1033. {
  1034.               if (tmppart[npart]->nrmonst)
  1035.                   yyerror("Monster registers already initialized!");
  1036.               else {
  1037.                   tmppart[npart]->rmonst = (char *) alloc(n_mlist);
  1038.                   memcpy(tmppart[npart]->rmonst, mlist, n_mlist);
  1039.                   tmppart[npart]->nrmonst = n_mlist;
  1040.               }
  1041.           } break;
  1042. case 22:
  1043. # line 307 "lev_comp.y"
  1044. {
  1045.               if (n_olist < MAX_REGISTERS)
  1046.                   olist[n_olist++] = yypvt[-0].i;
  1047.               else
  1048.                   yyerror("Object list too long!");
  1049.           } break;
  1050. case 23:
  1051. # line 314 "lev_comp.y"
  1052. {
  1053.               if (n_olist < MAX_REGISTERS)
  1054.                   olist[n_olist++] = yypvt[-2].i;
  1055.               else
  1056.                   yyerror("Object list too long!");
  1057.           } break;
  1058. case 24:
  1059. # line 322 "lev_comp.y"
  1060. {
  1061.               if (n_mlist < MAX_REGISTERS)
  1062.                   mlist[n_mlist++] = yypvt[-0].i;
  1063.               else
  1064.                   yyerror("Monster list too long!");
  1065.           } break;
  1066. case 25:
  1067. # line 329 "lev_comp.y"
  1068. {
  1069.               if (n_mlist < MAX_REGISTERS)
  1070.                   mlist[n_mlist++] = yypvt[-2].i;
  1071.               else
  1072.                   yyerror("Monster list too long!");
  1073.           } break;
  1074. case 26:
  1075. # line 337 "lev_comp.y"
  1076. {
  1077.               if (n_plist < MAX_REGISTERS)
  1078.                   plist[n_plist++] = current_coord;
  1079.               else
  1080.                   yyerror("Location list too long!");
  1081.           } break;
  1082. case 27:
  1083. # line 344 "lev_comp.y"
  1084. {
  1085.               if (n_plist < MAX_REGISTERS)
  1086.                   plist[n_plist++] = current_coord;
  1087.               else
  1088.                   yyerror("Location list too long!");
  1089.           } break;
  1090. case 41:
  1091. # line 366 "lev_comp.y"
  1092. {
  1093.               int token;
  1094.  
  1095.               tmpmonst[nmons] = (monster *) alloc(sizeof(monster));
  1096.               tmpmonst[nmons]->x = current_coord.x;
  1097.               tmpmonst[nmons]->y = current_coord.y;
  1098.               tmpmonst[nmons]->class = yypvt[-4].i;
  1099.               if (!yypvt[-2].map)
  1100.                   tmpmonst[nmons]->id = -1;
  1101.               else {
  1102.                   token = get_monster_id(yypvt[-2].map, (char) yypvt[-4].i);
  1103.                   if (token == ERR) {
  1104.                       yywarning("Illegal monster name!  Making random monster.");
  1105.                       tmpmonst[nmons]->id = -1;
  1106.                   } else
  1107.                       tmpmonst[nmons]->id = token;
  1108.               }
  1109.               nmons++;
  1110.           } break;
  1111. case 42:
  1112. # line 387 "lev_comp.y"
  1113. {
  1114.               int token;
  1115.  
  1116.               tmpobj[nobj] = (object *) alloc(sizeof(object));
  1117.               tmpobj[nobj]->x = current_coord.x;
  1118.               tmpobj[nobj]->y = current_coord.y;
  1119.               tmpobj[nobj]->class = yypvt[-4].i;
  1120.               if (!yypvt[-2].map)
  1121.                   tmpobj[nobj]->id = -1;
  1122.               else {
  1123.                   token = get_object_id(yypvt[-2].map, (char) yypvt[-4].i);
  1124.                   if (token == ERR) {
  1125.                       yywarning("Illegal object name!  Making random object.");
  1126.                       tmpobj[nobj]->id = -1;
  1127.                   } else
  1128.                       tmpobj[nobj]->id = token;
  1129.               }
  1130.               nobj++;
  1131.           } break;
  1132. case 43:
  1133. # line 408 "lev_comp.y"
  1134. {
  1135.             tmpdoor[ndoor] = (door *) alloc(sizeof(door));
  1136.             tmpdoor[ndoor]->x = current_coord.x;
  1137.             tmpdoor[ndoor]->y = current_coord.y;
  1138.             tmpdoor[ndoor]->mask = yypvt[-2].i;
  1139.             ndoor++;
  1140.           } break;
  1141. case 44:
  1142. # line 417 "lev_comp.y"
  1143. {
  1144.             tmptrap[ntrap] = (trap *) alloc(sizeof(trap));
  1145.             tmptrap[ntrap]->x = current_coord.x;
  1146.             tmptrap[ntrap]->y = current_coord.y;
  1147.             tmptrap[ntrap]->type = yypvt[-2].i;
  1148.             ntrap++;
  1149.           } break;
  1150. case 45:
  1151. # line 426 "lev_comp.y"
  1152. {
  1153.             tmpdb[ndb] = (drawbridge *) alloc(sizeof(drawbridge));
  1154.             tmpdb[ndb]->x = current_coord.x;
  1155.             tmpdb[ndb]->y = current_coord.y;
  1156.             tmpdb[ndb]->dir = db_dirs[yypvt[-2].i];
  1157.             if ( yypvt[-0].i == D_ISOPEN )
  1158.               tmpdb[ndb]->open = 1;
  1159.             else if ( yypvt[-0].i == D_CLOSED )
  1160.               tmpdb[ndb]->open = 0;
  1161.             else
  1162.               yyerror("A drawbridge can only be open or closed!");
  1163.             ndb++;
  1164.            } break;
  1165. case 46:
  1166. # line 441 "lev_comp.y"
  1167. {
  1168.             tmpwalk[nwalk] = (walk *) alloc(sizeof(walk));
  1169.             tmpwalk[nwalk]->x = current_coord.x;
  1170.             tmpwalk[nwalk]->y = current_coord.y;
  1171.             tmpwalk[nwalk]->dir = yypvt[-0].i;
  1172.             nwalk++;
  1173.           } break;
  1174. case 47:
  1175. # line 450 "lev_comp.y"
  1176. {
  1177.             tmplad[nlad] = (lad *) alloc(sizeof(lad));
  1178.             tmplad[nlad]->x = current_coord.x;
  1179.             tmplad[nlad]->y = current_coord.y;
  1180.             tmplad[nlad]->up = yypvt[-0].i;
  1181.             nlad++;
  1182.           } break;
  1183. case 48:
  1184. # line 459 "lev_comp.y"
  1185. {
  1186.             tmpdig[ndig] = (digpos *) alloc(sizeof(digpos));
  1187.             tmpdig[ndig]->x1 = current_region.x1;
  1188.             tmpdig[ndig]->y1 = current_region.y1;
  1189.             tmpdig[ndig]->x2 = current_region.x2;
  1190.             tmpdig[ndig]->y2 = current_region.y2;
  1191.             ndig++;
  1192.           } break;
  1193. case 49:
  1194. # line 469 "lev_comp.y"
  1195. {
  1196.             tmpreg[nreg] = (region *) alloc(sizeof(region));
  1197.             tmpreg[nreg]->x1 = current_region.x1;
  1198.             tmpreg[nreg]->y1 = current_region.y1;
  1199.             tmpreg[nreg]->x2 = current_region.x2;
  1200.             tmpreg[nreg]->y2 = current_region.y2;
  1201.             tmpreg[nreg]->rlit = yypvt[-2].i;
  1202.             tmpreg[nreg]->rtype = yypvt[-0].i;
  1203.             nreg++;
  1204.           } break;
  1205. case 50:
  1206. # line 481 "lev_comp.y"
  1207. {
  1208. #ifndef ALTARS
  1209.             yywarning("Altars are not allowed in this version!  Ignoring...");
  1210. #else
  1211.             tmpaltar[naltar] = (altar *) alloc(sizeof(altar));
  1212.             tmpaltar[naltar]->x = current_coord.x;
  1213.             tmpaltar[naltar]->y = current_coord.y;
  1214.             tmpaltar[naltar]->align = yypvt[-2].i;
  1215.             tmpaltar[naltar]->shrine = yypvt[-0].i;
  1216.             naltar++;
  1217. #endif /* ALTARS */
  1218.           } break;
  1219. case 52:
  1220. # line 496 "lev_comp.y"
  1221. {
  1222.               yyval.i = - MAX_REGISTERS - 1;
  1223.           } break;
  1224. case 55:
  1225. # line 503 "lev_comp.y"
  1226. {
  1227.               yyval.i = - MAX_REGISTERS - 1;
  1228.           } break;
  1229. case 58:
  1230. # line 510 "lev_comp.y"
  1231. {
  1232.               yyval.map = (char *) 0;
  1233.           } break;
  1234. case 60:
  1235. # line 516 "lev_comp.y"
  1236. {
  1237.               yyval.map = (char *) 0;
  1238.           } break;
  1239. case 61:
  1240. # line 521 "lev_comp.y"
  1241. {
  1242.             int token = get_trap_type(yypvt[-0].map);
  1243.             if (token == ERR)
  1244.                 yyerror("unknown trap type!");
  1245.             yyval.i = token;
  1246.           } break;
  1247. case 63:
  1248. # line 530 "lev_comp.y"
  1249. {
  1250.             int token = get_room_type(yypvt[-0].map);
  1251.             if (token == ERR) {
  1252.                 yywarning("Unknown room type!  Making ordinary room...");
  1253.                 yyval.i = OROOM;
  1254.             } else
  1255.                 yyval.i = token;
  1256.           } break;
  1257. case 67:
  1258. # line 543 "lev_comp.y"
  1259. {
  1260.               current_coord.x = current_coord.y = -MAX_REGISTERS-1;
  1261.           } break;
  1262. case 74:
  1263. # line 556 "lev_comp.y"
  1264. {
  1265.               yyval.i = - MAX_REGISTERS - 1;
  1266.           } break;
  1267. case 77:
  1268. # line 564 "lev_comp.y"
  1269. {
  1270.             if ( yypvt[-1].i >= MAX_REGISTERS ) {
  1271.                 yyerror("Register Index overflow!");
  1272.             } else {
  1273.                 current_coord.x = current_coord.y = - yypvt[-1].i - 1;
  1274.             }
  1275.           } break;
  1276. case 78:
  1277. # line 573 "lev_comp.y"
  1278. {
  1279.             if ( yypvt[-1].i >= MAX_REGISTERS ) {
  1280.                 yyerror("Register Index overflow!");
  1281.             } else {
  1282.                 yyval.i = - yypvt[-1].i - 1;
  1283.             }
  1284.           } break;
  1285. case 79:
  1286. # line 582 "lev_comp.y"
  1287. {
  1288.             if ( yypvt[-1].i >= MAX_REGISTERS ) {
  1289.                 yyerror("Register Index overflow!");
  1290.             } else {
  1291.                 yyval.i = - yypvt[-1].i - 1;
  1292.             }
  1293.           } break;
  1294. case 80:
  1295. # line 591 "lev_comp.y"
  1296. {
  1297.             if ( yypvt[-1].i >= 3 ) {
  1298.                 yyerror("Register Index overflow!");
  1299.             } else {
  1300.                 yyval.i = - yypvt[-1].i - 1;
  1301.             }
  1302.           } break;
  1303. case 82:
  1304. # line 602 "lev_comp.y"
  1305. {
  1306.             if (check_monster_char((char) yypvt[-0].i))
  1307.                 yyval.i = yypvt[-0].i ;
  1308.             else {
  1309.                 yyerror("unknown monster class!");
  1310.                 yyval.i = ERR;
  1311.             }
  1312.           } break;
  1313. case 83:
  1314. # line 612 "lev_comp.y"
  1315. {
  1316.             char c;
  1317.  
  1318.             c = yypvt[-0].i;
  1319. #ifndef SPELLS
  1320.             if ( c == '+') {
  1321.                 c = '?';
  1322.                 yywarning("Spellbooks are not allowed in this version! (converted into scroll)");
  1323.             }
  1324. #endif
  1325.             if (check_object_char(c))
  1326.                 yyval.i = c;
  1327.             else {
  1328.                 yyerror("Unknown char class!");
  1329.                 yyval.i = ERR;
  1330.             }
  1331.           } break;
  1332. case 85:
  1333. # line 632 "lev_comp.y"
  1334. {
  1335.             if (yypvt[-3].i < 0 || yypvt[-3].i > max_x_map ||
  1336.                 yypvt[-1].i < 0 || yypvt[-1].i > max_y_map)
  1337.                 yyerror("Coordinates out of map range!");
  1338.             current_coord.x = yypvt[-3].i;
  1339.             current_coord.y = yypvt[-1].i;
  1340.           } break;
  1341. case 86:
  1342. # line 641 "lev_comp.y"
  1343. {
  1344.             if (yypvt[-7].i < 0 || yypvt[-7].i > max_x_map ||
  1345.                 yypvt[-5].i < 0 || yypvt[-5].i > max_y_map ||
  1346.                 yypvt[-3].i < 0 || yypvt[-3].i > max_x_map ||
  1347.                 yypvt[-1].i < 0 || yypvt[-1].i > max_y_map)
  1348.                 yyerror("Region out of map range!");
  1349.             current_region.x1 = yypvt[-7].i;
  1350.             current_region.y1 = yypvt[-5].i;
  1351.             current_region.x2 = yypvt[-3].i;
  1352.             current_region.y2 = yypvt[-1].i;
  1353.           } break; 
  1354.         }
  1355.         goto yystack;  /* stack new state and value */
  1356.  
  1357.     }
  1358.